<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-on</title>
    <script src="../assets/vue.js"></script>
</head>
<body>
<h1>v-on实例</h1>
<hr>
<div id="app">
    本场比赛得分：{{score}}
    <p>
        <button v-on:click="add">加分</button>
        <button @click="num">减分</button>
        <br>
        <input type="text" v-on:keyup.enter="director" v-model="score2">
    </p>
</div>
<script>
    var app = new Vue({
        el:'#app',
        data:{
            score:0,
            score2:0
        },
        methods:{
            add:function(){
                this.score++
            },
            num:function(){
                this.score--
            },
            director:function(){
                this.score += +this.score2
            }
        }
    })
</script>
</body>
</html>